home *** CD-ROM | disk | FTP | other *** search
- The\ `tcl'\ Mode\n\nIntroduction\nThe\ tcl\ mode\ of\ jedit\ is\ intended\ for\ editing\ Tcl\ code.\ \ Among\ its\ major\ features\ are\ a\ `Procs'\ menu\ that\ lets\ you\ quickly\ jump\ to\ a\ particular\ procedure\ definition\ and\ rudimentary\ support\ for\ automatic\ indentation.\n\nThis\ document\ describes\ the\ tcl\ mode\ available\ with\ version\ 3.6/3.0\ of\ jedit.\n\nPreferences\nIn\ tcl\ mode,\ by\ default,\ the\ Space\ and\ Return\ keys\ do\ not\ do\ abbreviation\ expansion\ (although\ you\ can\ do\ it\ by\ hand\ with\ the\ commands\ on\ the\ `Abbrev'\ menu),\ lines\ do\ not\ have\ newlines\ inserted\ automatically\ as\ you\ approach\ the\ right\ margin,\ and\ when\ you\ type\ a\ closing\ parenthesis,\ bracket\ or\ brace,\ the\ corresponding\ opening\ character\ briefly\ flashes\ (assuming\ it's\ visible\ on\ the\ screen).\ \ Also,\ new\ lines\ start\ with\ the\ same\ indentation\ as\ the\ preceeding\ line,\ except\ as\ modified\ by\ tcl\ mode's\ automatic\ indentation,\ described\ below.\ \ Of\ course,\ you\ can\ change\ any\ of\ these\ settings\ on\ the\ Mode¡Specific\ Preferences\ panel.\n\nThe\ `Tcl'\ Menu\ and\ the\ Buttonbar\nThe\ tcl\ mode\ provides\ a\ `Tcl'\ menu\ with\ commands\ for\ manipulating\ comments.\n\nComment\ with\ #\n`Comment\ with\ #'\ prepends\ a\ hash\ mark\ and\ a\ space\ to\ each\ line\ of\ the\ selected\ text.\ \ It's\ useful\ for\ commenting\ out\ sections\ of\ code.\n\nComment\ with\ ###\n`Comment\ with\ ###'\ functions\ identically\ to\ `Comment\ with\ #',\ except\ that\ it\ uses\ three\ hash\ marks\ instead\ of\ one.\ \ I\ use\ this\ to\ comment\ out\ sections\ of\ code\ that\ I\ want\ to\ call\ my\ attention\ to\ later.\n\nUncomment\n`Uncomment'\ removes\ any\ number\ of\ hash\ marks\ followed\ by\ a\ space\ from\ the\ beginning\ of\ the\ selected\ lines.\ \ (Tip:\ \ You\ can\ reformat\ commented\ prose\ by\ selecting\ it,\ choosing\ `Uncomment',\ choosing\ `Format\ lines\ with\ ``fmt'''\ from\ the\ `Format'\ menu,\ and\ choosing\ `Comment\ with\ #'.)\n\nMake\ Border\n`Make\ Border'\ inserts\ a\ line\ consisting\ of\ 70\ hash\ marks,\ followed\ by\ a\ newline.\ \ I\ use\ this\ as\ part\ of\ my\ block\ comments\ before\ procedure\ definitions,\ and\ sometimes\ as\ a\ separator.\n\nThe\ Buttonbar\nThe\ tcl¡mode\ buttonbar\ has\ buttons\ which\ duplicate\ the\ functions\ of\ the\ commands\ on\ the\ `Tcl'\ menu,\ and\ also\ a\ `Save'\ button\ which\ duplicates\ the\ `Save'\ command\ on\ the\ `File'\ menu.\n\nThe\ `Procs'\ Menu\nThe\ `Procs'\ menu\ provides\ a\ dynamic\ list\ of\ all\ the\ procedure\ definitions\ in\ the\ current\ file.\ \ You\ can\ choose\ a\ procedure\ name\ from\ the\ `Procs'\ menu\ to\ jump\ quickly\ to\ the\ specified\ procedure\ definition.\n\nThe\ `Procs'\ menu\ is\ generated\ by\ searching\ the\ text\ \ for\ lines\ starting\ with\ the\ characters\ `proc'\ followed\ by\ a\ space\ or\ a\ tab,\ so\ it\ may\ not\ list\ procedures\ defined\ in\ an\ unusual\ coding\ style.\ \ (On\ the\ other\ hand,\ Tcl's\ auto_mkindex\ procedure\ probably\ wouldn't\ find\ them\ either.)\n\nAutomatic\ Indentation\nNormally,\ as\ you\ type\ in\ tcl\ mode,\ each\ line\ gets\ the\ same\ indentation\ as\ the\ previous\ line\ had.\ \ However,\ tcl\ mode\ has\ a\ little\ understanding\ of\ Tcl\ syntax,\ and\ will\ adjust\ the\ indentation\ of\ lines\ in\ some\ circumstances.\ \ The\ intention\ is\ that\ you\ should\ be\ able\ to\ type\ Tcl\ code\ without\ having\ to\ worry\ about\ indentation,\ and\ the\ code\ should\ be\ automatically\ indented\ for\ you.\n\nIn\ particular,\ when\ a\ line\ ends\ with\ an\ opening\ brace\ (possibly\ followed\ by\ a\ comment),\ the\ indentation\ of\ the\ following\ line\ is\ increased,\ and\ when\ a\ line\ starts\ with\ a\ closing\ brace,\ it's\ indentation\ is\ decreased\ when\ you\ hit\ Return.\ \ Also,\ when\ a\ line\ ends\ with\ a\ backslash,\ the\ indentation\ of\ a\ following\ line\ is\ increased.\ \ (Indentation\ is\ restored\ following\ the\ next\ line\ that\ does\ not\ end\ in\ a\ backslash.\n\nIt\ may\ be\ a\ little\ clearer\ to\ see\ some\ examples\ of\ Tcl\ code\ whose\ indentation\ tcl\ mode\ handles\ well:\n\tframe\ .foo\ \\\n\t\ \ -width\ 10\ -height\ 20\ \\\n\t\ \ -background\ blue\n\t\n\tproc\ foo\ {}\ {\n\t\ \ global\ bar\n\t\ \ if\ \$bar\ {\ \ \ \;\ #\ comment\n\t\ \ \ \ baz\n\t\ \ }\ else\ {\ }\n\t}\n\t\n\tformat\ {\n\t\ \ %d\ dollars,\n\t\ \ %d\ cents.\n\t}\ \$dollars\ \$cents\n\nHowever,\ tcl\ mode's\ parsing\ is\ not\ very\ elaborate.\ \ In\ particular,\ it\ has\ trouble\ with\ the\ following\ constructions:\n\tset\ foo\ {\n\t\ \ bar\n\t\ \ baz}\ \;#\ close\ brace\ not\ at\ beginning\ of\ line\n\t\n\tcatch\ {\n\t\ \ \$t\ tag\ configure\ comment\ -foreground\ grey50\ \\\n\t\ \ \ \ -font\ -*-lucida-medium-r-normal-sans-10-100-*\n\t}\ \;#\ last\ line\ before\ close\ brace\ is\ a\ continuation\n\nAlso,\ use\ of\ braces\ to\ delimit\ strings\ may\ confuse\ it,\ and\ use\ of\ double\ quotation\ marks\ spanning\ multi¡line\ stretches\ of\ Tcl\ code\ will\ confuse\ it.\n\nFurthermore,\ the\ automatic\ indentation\ of\ each\ line\ relies\ on\ the\ assumption\ that\ the\ indentation\ of\ the\ preceding\ line\ is\ already\ correct,\ and\ there's\ no\ mechanism\ (as\ there\ is\ in\ GNU\ Emacs,\ for\ instance)\ to\ automatically\ re¡indent\ a\ stretch\ of\ existing\ code.\n\nSee\ Also\n\tThe\ `code'\ Mode\n\nComment\ Highlighting\nThere's\ some\ code\ in\ the\ file\ that\ implements\ tcl\ mode\ (normally\ installed\ as\ /usr/local/lib/jstools/jeditmodes/tcl-mode.tcl)\ for\ automatic\ highlighting\ of\ comments,\ but\ that\ code\ is\ currently\ disabled,\ because\ it's\ very\ slow.\ \ If\ you\ want\ to\ experiment\ with\ it,\ you\ can\ copy\ that\ file\ to\ your\ ~/.tk/jeditmodes\ directory\ and\ re¡enable\ it.\n\nEvolution\nBugs\ and\ Limitations\n*\ In\ addition\ to\ the\ limitations\ mentioned\ above\ under\ Automatic\ Indentation,\ the\ main\ problem\ with\ tcl\ mode\ is\ that\ indentation\ is\ hardwired\ to\ two\ per\ level\ of\ nesting.\n\nFuture\ Directions\n*\ Perhaps\ tcl\ mode\ can\ do\ some\ syntax¡dependent\ highlighting\ along\ the\ lines\ of\ the\ disabled\ comment¡finding\ code.\ \ This\ should\ be\ much\ more\ efficient\ in\ Tk\ 4.\n\n*\ There\ should\ be\ a\ set\ of\ preferences\ for\ things\ like\ indentation\ depth\ and\ whether\ to\ highlight\ keywords\ or\ comments.\ \ This\ will\ require\ changes\ to\ jedit's\ mode¡\ and\ preference¡handling\ mechanisms.\n {{{jdoc:xref:link {4.16 4.21 9.497 9.518 71.1 71.16 78.55 78.76 83.150 83.155}} {jdoc:anchor:anchorname {3.0 4.0 8.0 9.0 11.0 12.0 29.0 30.0 34.0 35.0 70.0 71.0 73.0 74.0 76.0 78.0}} {richtext:font:roman {2.0 3.0 4.0 4.4 4.7 4.16 4.21 6.28 6.31 6.71 6.76 8.0 9.0 9.3 9.6 9.29 9.34 9.39 9.45 9.486 9.489 11.0 12.0 12.4 12.7 14.0 15.0 17.0 18.0 20.0 21.0 23.0 24.0 26.0 27.0 27.4 27.7 29.0 30.0 32.93 32.97 32.222 32.234 34.0 35.0 35.25 35.28 35.107 35.110 37.156 37.162 37.228 37.234 39.78 39.81 40.0 55.0 56.9 56.12 57.0 65.0 70.0 71.0 71.1 71.16 73.0 74.0 74.46 74.49 74.78 74.124 74.294 74.310 76.0 78.0 78.55 78.76 78.100 78.103 80.0 81.0 81.10 81.13 83.150 83.155 84.0}} {richtext:font:italic {37.156 37.162}} {richtext:font:bold {9.29 9.34 9.39 9.45 37.228 37.234 74.78 74.124 74.294 74.310}} {richtext:font:bolditalic {71.1 71.16 78.55 78.76}} {richtext:font:typewriter {4.4 4.7 4.16 4.21 6.28 6.31 6.71 6.76 9.3 9.6 9.486 9.489 12.4 12.7 27.4 27.7 32.93 32.97 32.222 32.234 35.25 35.28 35.107 35.110 39.78 39.81 40.0 55.0 56.9 56.12 57.0 65.0 74.46 74.49 78.100 78.103 81.10 81.13 83.150 83.155}} {richtext:font:heading0 {1.0 2.0}} {richtext:font:heading1 {3.0 4.0 8.0 9.0 11.0 12.0 29.0 30.0 34.0 35.0 70.0 71.0 73.0 74.0 76.0 77.0}} {richtext:font:heading2 {14.0 15.0 17.0 18.0 20.0 21.0 23.0 24.0 26.0 27.0 77.0 78.0 80.0 81.0}} {jdoc:anchorname:Introduction {3.0 4.0}} {jdoc:link:jedit.jdoc {4.16 4.21 83.150 83.155}} {jdoc:anchorname:Preferences {8.0 9.0}} {jdoc:anchorname:The_`Tcl'_Menu_and_the_Buttonbar {11.0 12.0}} {jdoc:anchorname:The_`Procs'_Menu {29.0 30.0}} {jdoc:link:#Automatic_Indentation {9.497 9.518 78.55 78.76}} {jdoc:anchorname:Automatic_Indentation {34.0 35.0}} {jdoc:link:jeditmodes/code-mode.jdoc {71.1 71.16}} {jdoc:anchorname:See_Also {70.0 71.0}} {jdoc:anchorname:Comment_Highlighting {73.0 74.0}} {jdoc:anchorname:Bugs_and_Limitations {77.0 78.0}} {jdoc:anchorname:Evolution {76.0 77.0}}} {{matchend 74.258} {abbrevstart 76.9} {abbrevend 76.9} {insert 6.67} {matchstart 74.254} {anchor 6.67} {current 1.0}}}